classdef jwlong_apsyn_class
    %     1、执行构造函数
    %     source = jwlong_apsyn_class;
    %     2、执行连接函数
    %     [source.obj,source.idn]=source.Conect(...
    %         'USB0::0x03EB::0xAFFF::321-03A100000-0286::0::INSTR');
    %     3、执行设置
    %     source.SetFreq(source,5.8e9);
    
    properties
        obj % 连接仪器的对象       
        idn % 保存仪器的编号    
    end
    
    methods
        function source = jwlong_apsyn_class
            %  构造此类的实例
        end
    end
    
    methods(Static)      
        function [obj,idn] = Conect(visa_address)
            % 连接仪器，同时读取仪器编号
            obj=visadev(visa_address);
            % 考虑使用 visadevlist, visadev
            writeline(obj,"*IDN?");
            idn=readline(obj);
        end
        
        function SetFreq(source,freq)
            % 设置频率
            writeline(source.obj,['SOURce:FREQuency:CW ',num2str(freq)]); 
        end 
        
        function OpenRF(source)
            % 打开射频
            writeline(source.obj,':OUTPut:STATe ON');
        end
        
        function CloseRF(source)
            % 关闭射频
            writeline(source.obj,':OUTPut:STATe OFF');
        end
        
        function freq=ReadData(source)
            % 读取当前频率
            writeline(source.obj,'SOURce:FREQuency:CW?');
            freq=str2double(readline(source.obj));  
        end
        
        
    end
end

